<template>
    <div @click="loginIn">登录</div>
</template>

<script setup>
import { useRouter, useRoute } from 'vue-router'
const router = useRouter()
const route = useRoute()

const loginIn = () => {
    const periodValidity = new Date().getTime() + 1000 * 60 * 60 * 24 * 7
    localStorage.setItem('token', '123456')
    localStorage.setItem('periodValidity', periodValidity)
    const redirect = route.query.redirect || '/'
    router.push(redirect)
}
</script>